//
//  BaseNavViewController.m
//  SXparent
//
//  Created by HuangSui on 16/9/26.
//  Copyright © 2016年 SuiXun. All rights reserved.
//

#import "BaseNavViewController.h"

@interface BaseNavViewController ()

@end

@implementation BaseNavViewController


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //适配ios7
    if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0))
    {
 //      这一句会导致所有界面同时加载
 //      viewController.view.backgroundColor=[UIColor colorF];
 //      viewController.navigationController.navigationBar.translucent = NO;
       [self setEdgesForExtendedLayout:UIRectEdgeNone];
 
        viewController.automaticallyAdjustsScrollViewInsets=NO;
        
        
    }
    
    if ([viewController isKindOfClass:[HomeViewController class]] ||[viewController isKindOfClass:[AccountViewController class]] ||[viewController isKindOfClass:[MyViewController class]]||[viewController isKindOfClass:[LogViewController class]] ||[viewController isKindOfClass:[ElectrombileViewController class]] ||[viewController isKindOfClass:[TypeColorViewController class]] ||[viewController isKindOfClass:[AccountManageViewController class]] ) {
        
    }else
    {
        UIButton *backBtn=[NetworkPath SetNavLeftBtnWithController:viewController withTitle:nil andImageName:@"返回"];
        [backBtn addTarget:self action:@selector(backBarButtonPressed) forControlEvents:UIControlEventTouchUpInside];
        

        
        
        // 隐藏底部的工具条
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.view.backgroundColor=[UIColor colorF];
    }
   
    [super pushViewController:viewController animated:animated];
}
/// 返回按钮事件处理
- (void)backBarButtonPressed
{
    
//    /// 可以返回到上一个网页，就返回到上一个网页
//    if (self.webView.canGoBack) {
//            [self.webView goBack];
//    }else{/// 不能返回上一个网页，就返回到上一个界面
//            /// 判断 是Push还是Present进来的，
//    if (self.presentingViewController) {
//        [self dismissViewControllerAnimated:YES completion:^{
//            
//        }];
//    } else {
//        [self popViewControllerAnimated:YES];
//            }
//    }
    
    [super popViewControllerAnimated:YES];

}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    //    [self.view endEditing:YES];
    //    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
    //    [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
    [super touchesBegan:touches withEvent:event];
}
@end
